{{#if canInviteToForum}}
  <section class='user-content'>

    <h2>{{i18n 'user.invited.title'}}</h2>

    <div class="pull-right">
      <button {{action "showInvite"}} class='btn'>{{i18n 'user.invited.create'}}</button>
      {{#if canBulkInvite}}
        {{resumable-upload target="/invites/upload" success="uploadSuccess" error="uploadError" uploadText=uploadText}}
      {{/if}}
    </div>

    {{#if showSearch}}
      <form>
        {{text-field value=searchTerm placeholderKey="user.invited.search"}}
      </form>
    {{/if}}

    {{#if model.invites}}
      <table class='table invite-list'>
        <tr>
          <th>{{i18n 'user.invited.user'}}</th>
          <th>{{i18n 'user.invited.redeemed_at'}}</th>
          {{#if can_see_invite_details}}
            <th>{{i18n 'user.last_seen'}}</th>
            <th>{{i18n 'user.invited.topics_entered'}}</th>
            <th>{{i18n 'user.invited.posts_read_count'}}</th>
            <th>{{i18n 'user.invited.time_read'}}</th>
            <th>{{i18n 'user.invited.days_visited'}}</th>
          {{/if}}
        </tr>
        {{#each invite in model.invites}}
          <tr>
            {{#if invite.user}}
              <td>
                {{#link-to 'user' invite.user}}{{avatar invite.user imageSize="tiny"}}{{/link-to}}
                {{#link-to 'user' invite.user}}{{invite.user.username}}{{/link-to}}
              </td>
              <td>{{format-date invite.redeemed_at}}</td>
              {{#if can_see_invite_details}}
                <td>{{format-date invite.user.last_seen_at}}</td>
                <td>{{number invite.user.topics_entered}}</td>
                <td>{{number invite.user.posts_read_count}}</td>
                <td>{{{unbound invite.user.time_read}}}</td>
                <td><span title="{{i18n 'user.invited.days_visited'}}">{{{unbound invite.user.days_visited}}}</span>
                    /
                  <span title="{{i18n 'user.invited.account_age_days'}}">{{{unbound invite.user.days_since_created}}}</span></td>
              {{/if}}
            {{else}}
              <td>{{unbound invite.email}}</td>
              <td colspan='6'>
                {{#if invite.expired}}
                  {{i18n 'user.invited.expired'}}
                  &nbsp;&nbsp;&nbsp;&nbsp;
                {{/if}}
                {{#if invite.rescinded}}
                  {{i18n 'user.invited.rescinded'}}
                {{else}}
                  <button class='btn' {{action "rescind" invite}}><i class="fa fa-times"></i>{{i18n 'user.invited.rescind'}}</button>
                {{/if}}
                &nbsp;&nbsp;&nbsp;&nbsp;
                {{#if invite.reinvited}}
                  {{i18n 'user.invited.reinvited'}}
                {{else}}
                  <button class='btn' {{action "reinvite" invite}}><i class="fa fa-user-plus"></i>{{i18n 'user.invited.reinvite'}}</button>
                {{/if}}
              </td>
            {{/if}}
          </tr>
        {{/each}}
      </table>
      {{conditional-loading-spinner condition=invitesLoading}}

    {{else}}
      {{#if canBulkInvite}}
        {{{i18n 'user.invited.bulk_invite.none'}}}
      {{else}}
        {{i18n 'user.invited.none'}}
      {{/if}}
    {{/if}}

  </section>
{{/if}}
